//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include<sysmac.h>
#include<dstring.h>

#include "Unit2.h"
void getNameAndSales();
double s[4];
AnsiString d[4],extreme;
int flag1,flag2;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{

d[0]=this->Edit1->Text ;
d[1]=this->Edit2->Text ;
d[2]=this->Edit3->Text ;
d[3]=this->Edit4->Text ;

s[0]=this->Edit5->Text.ToInt();
s[1]=this->Edit6->Text.ToInt();
s[2]=this->Edit7->Text.ToInt();
s[3]=this->Edit8->Text.ToInt();





}





//---------------------------------------------------------------------------
void findExtreme()
{
	  if(s[0]>=s[1]&&s[0]>=s[2]&&s[0]>=s[3])
 {
	 flag1=0;
 }
 else if(s[1]>=s[0]&&s[1]>=s[2]&&s[1]>=s[3])
 {
	 flag1=1;
 }
 else if(s[2]>=s[1]&&s[2]>=s[0]&&s[2]>=s[3])
 {
	 flag1=2;
 }
 else if(s[3]>=s[0]&&s[3]>=s[2]&&s[3]>=s[0])
 {
	 flag1=3;
 }
	if(s[0]<=s[1]&&s[0]<=s[2]&&s[0]<=s[3])
 {
	 flag2=0;
 }
 else if(s[1]<=s[0]&&s[1]<=s[2]&&s[1]<=s[3])
 {
	 flag2=1;
 }
 else if(s[2]<=s[1]&&s[2]<=s[0]&&s[2]<=s[3])
 {
	 flag2=2;
 }
 else if(s[3]<=s[0]&&s[3]<=s[2]&&s[3]<=s[0])
 {
	 flag2=3;
 }


 }

 void getNameAndSales()
{




}

void __fastcall TForm2::Button2Click(TObject *Sender)
{
findExtreme();
this->Edit9->Text=AnsiString(d[flag1]);
this->Edit10->Text=AnsiString(d[flag2]);
}
//---------------------------------------------------------------------------

